  function dispatchEvent(componentName,EventName,Val){
    let parent = this.$parent
    while(parent){
        if(parent.$options.componentName===componentName){
            parent.$emit.call(parent,EventName,Val)
            return
        }else{
            parent = parent.$parent
        }
    }
}



 function boardcast(componentName,EventName,Val){
     
    this.$children.forEach(Item=>{
        if(Item.$options.componentName!=componentName){
            boardcast.call(Item,componentName,EventName,Val)
        }else{
            Item.$emit(EventName,Val)
        }
    })
}

export default {
    methods:{
        dispatchEvent,
        boardcast
    }
}